package cglib;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodProxy;
import net.sf.cglib.proxy.MethodInterceptor;

public class Main1 {
	public static void main(String[] args) {
		Enhancer enhancer = new Enhancer();

		enhancer.setSuperclass(MyClass.class);
		enhancer.setCallback(new MethodInterceptorImpl());

		MyClass my = (MyClass) enhancer.create();

		my.method();
	}

	private static class MethodInterceptorImpl implements MethodInterceptor {

		public Object intercept(Object obj, Method method, Object[] args,
				MethodProxy proxy) throws Throwable {


			proxy.invokeSuper(obj, args);
			System.out.println(method);

			return null;
		}
	}
}
